import dayjs from 'dayjs';
import { trim } from 'lodash';

export const u_formatDateTime = (dateTime: string, template: string = 'YYYY-MM-DD HH:mm') => {
    if (trim(dateTime) === '') {
        return ''
    }
    return dayjs(dateTime).format(template);
}

export const u_calculateDate = (date?: string, opt?: number) => {
    let _date = dayjs(date);
    if (opt) {
        _date = _date.add(opt, 'day')
    }
    return _date.format('YYYYMMDD')
}